<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="referrer" content="no-referrer" />
    <title>{$active.name}wx</title>
    {include file='default/public/header'/}
    <link href="__PUBLIC__/index/finishing/css/reset.css" type="text/css" rel="stylesheet" />
    <link href="__PUBLIC__/index/finishing/css/find.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
/*        .iframe-box{
            width:100%;height:100%;background: rgba(0,0,0,.5);position: fixed;z-index: 10000000;display: none;
        }
        .my_float_box{
            margin: auto;
            width: 90%;
            height: 80%;
            border: none;
            background: #ffffff;
            padding: 10px;
            overflow: auto;
            margin-top: 10%;
        }
        .fall-box .item{margin-left:0.2rem;margin-bottom: 0.5rem;}
        .sign-item-number-box{background:{$active.theme_color};}
        .sign-item-number-box-jiao{border-top-color:{$active.theme_color};}
        .sign-item-btn{background: #f65564;}*/

        .iframe-box{
            width:100%;height:100%;background: rgba(0,0,0,.5);position: fixed;z-index: 10000000;display: none;
        }
        .my_float_box{
            margin: auto;
            width: 90%;
            height: 80%;
            border: none;
            background: #ffffff;
            padding: 10px;
        }
        .fall-box .item{margin-bottom: 0.5rem;}

    </style>
</head>
<body >
<div class="page-group">
    <div class="page">
        <div class="content">

<!--             <div class="iframe-box">
                <div class="intro-box content my_float_box" style="overflow-y:scroll"> -->
<!--                     <h4>微信投票：</h4>
                    <p>微信端每日限投票1次，1次2分</p>
                    <h4>APP投票：</h4>
                    <p>APP端每日限投票3次，1次2分</p>
                    <p>凡APP参与投票的用户，即可获得1次0.1-8.8随机现金红包</p> -->
<!--                     <p><img src="__PUBLIC__/index/images/sm_55.jpg" width="100%"></p>
                </div>
            </div> -->

            <nav class="bar bar-tab" style="height:0;top: 0;">
                {include file='default/public/fixed'/}
            </nav>
            {include file='default/public/nav'/}
            <div class="nav-box">
                <div class="nav-item new-signer">
                    <div style="background: {$active.btn_info.color};border-radius: 5px;">{$active.btn_info.text.0}</div>
                </div>
                <div class="nav-item support-signer">
                    <div style="background: {$active.btn_info.color};border-radius: 5px;">{$active.btn_info.text.1}</div>
                </div>
    <!--             <div class="nav-item my_detail">
                    <div style="background: {$active.btn_info.color};border-radius: 5px;">{$active.btn_info.text.2}</div>
                </div> -->
            </div>

            <div class="list-box" style="padding:5% 8px">
                {if condition="$count > 0"}
                <aside class="fall-box grid" style="margin: 0">
                    {foreach $list as $item}
                    <div class="grid-item item sign-item">
                        <div class="detail-jump" data-user-id="{$item.user_id}"  onclick="">
                            <div class="sign-item-number-box">
                                {$item.contestant_number}号
                                <div class="sign-item-number-box-jiao">&nbsp;</div>
                            </div>
                            <div class="sign-item-img-box">
                                {if condition="$item.cover"}
                                    <!-- if condition="strpos($item.cover,'magapp') !== false" -->
                                    {if condition="$item.sign_pass_way == 'yqsbz'"}
                                    <img src="{$item.cover}&width=150&height=60" class="item-img" />
                                    {else/}
                                    <!-- <img src="{$item.cover}?x-oss-process=image/resize,w_150" class="item-img" /> -->
                                    <img src="{$item.cover}" class="item-img" />
                                    {/if}
                                {else/}
                                    <!-- if condition="strpos($item.images.0,'magapp') !== false" -->
                                    {if condition="$item.sign_pass_way == 'yqsbz'"}
                                    <img src="{$item.images2}&width=150&height=60" class="item-img" />
                                    {else/}
                                    <img src="{$item.images2}" class="item-img" />
                                    {/if}
                                {/if}
                                <div class="clear"></div>
                            </div>
                            <div class="sign-item-text-box-1">
                                <div>{$item.nickname}</div>
                                <div style="display: flex;"><span id="list{$item.id}">{$item.support}</span>朵</div>
                            </div>
                        </div>
                        <div class="sign-item-btn-box">
                            <div class="sign-item-btn  vote_btn" data-id="{$item.id}" data-user-id="{$item.user_id}" onclick="">送{$number}朵</div>
                        </div>
                    </div>
                    {/foreach}
                </aside>
                {else/}
                <div class="sign-list-box">
                    <div class="null-box">
                        {if condition="$keywords"}
                        搜索结果为空
                        {else/}
                        暂无人员报名
                        {/if}
                    </div>
                </div>
                {/if}
            </div>
            {eq name="$count" value="10"}
            <div class="more-btn-box">
                <div class="more-btn" style="background: {$active.theme_color};">
                    更多
                </div>
            </div>
            {/eq}
            <div>
                <img src="{$active.end_img}" style="width:100%;float:left;"/>
            </div>
        </div>
    </div>
</div>
{include file='default/public/js'/}
<script type="text/javascript">
    $('.my_detail').click(function(){
        location.href='{:url("detail",["id"=>$active.id])}';
    });
    var boundary = '{$boundary}',order = '{$order}';
    $('.more-btn').click(function(){
        $.showLoading();
        $.ajax({
            dataType:"json",
            type:'post',
            url:'{:url("ajax_list")}',
            data:'id={$id}&boundary='+boundary+'&order='+order+'&keywords='+$('input[name=keywords]').val(),
            success:function(result){
                if(result.data.count < 10 ){
                    $('.more-btn-box').hide();
                }
                if(result.code==0){
                    boundary = result.data.boundary;
                    appendFall( result.data.list,result.data.number);
                }
                $.hideLoading();
            },
            error:function(e){
                console.log('请求失败')
            }

        })
    });
    var $grid = $('.grid').masonry({
        itemSelector : '.grid-item',
        gutter:10
    });
    // layout Masonry after each image loads
    $grid.imagesLoaded().done( function() {
        //console.log('uuuu===');
        $grid.masonry('layout');
    });
    function appendFall(dataFall,number){
        $.each(dataFall, function(index ,value) {
            var dataLength = dataFall.length;
            $grid.imagesLoaded().done( function() {
                $grid.masonry('layout');
            });
            var detailUrl;
            var $griDiv = $('<div class="grid-item item sign-item"></div>');
            var $detail = $('<div class="detail-jump" data-user-id="'+value.user_id+'"  onclick="">');
            $detail.html('<div class="sign-item-number-box">'+value.contestant_number+'号 <div class="sign-item-number-box-jiao">&nbsp;</div> </div>').appendTo($griDiv);
            var $imgBox = $('<div class="sign-item-img-box">');
            $imgBox.appendTo($detail);
            var $img = $("<img class='item-img'>");
            // if(value.cover){
            //     if(value.cover.indexOf("magapp") > 0){
            //         $img.attr('src',value.cover+'&width=150&height=60').appendTo($imgBox);
            //     }else{
            //         $img.attr('src',value.cover+'?x-oss-process=image/resize,w_150').appendTo($imgBox);
            //     }
            // }else{
            //     if(value.images[0].indexOf("magapp") > 0){
            //         $img.attr('src',value.images[0]+'&width=150&height=60').appendTo($imgBox);
            //     }else{
            //         $img.attr('src',value.images[0]+'?x-oss-process=image/resize,w_150').appendTo($imgBox);
            //     }
            // }
            if(value.cover){
                if(value.cover.indexOf("magapp") > 0){
                    $img.attr('src',value.cover+'&width=150&height=60').appendTo($imgBox);
                }else{
                    $img.attr('src',value.cover).appendTo($imgBox);
                }
            }else{
                if(value.images[0].indexOf("magapp") > 0){
                    $img.attr('src',value.images[0]+'&width=150&height=60').appendTo($imgBox);
                }else{
                    $img.attr('src',value.images[0]).appendTo($imgBox);
                }
            }
            var clear = $('<div class="clear">').appendTo($imgBox);
            var $section = $('<div class="sign-item-text-box-1">');
            $section.appendTo($griDiv);
            var $p1 = $('<div>');
            $p1.html(value.nickname).appendTo($section);
            var $p2 = $('<div>');
            $p2.html('<div style="display: flex;"><span id="list'+value.id+'">'+value.support+'</span>朵</div>').appendTo($section);
            var $tou = $('<div class="sign-item-btn-box">');
            $tou.html('<div class="sign-item-btn vote_btn" data-id="'+value.id+'" data-user-id="'+value.user_id+'" onclick="">送'+number+'朵</div>').appendTo($griDiv);
            var $items = $griDiv;
            $items.imagesLoaded().done(function(){
                $grid.masonry('layout');
                $grid.append( $items ).masonry('appended', $items);
            })
        });
    }

    $('.new-signer').click(function(){
        location.href = '{:url("index",["order"=>1,"id"=>$active["id"]])}';
    });

    $('.support-signer').click(function(){
        location.href = '{:url("index",["order"=>2,"id"=>$active["id"]])}';
    });

    $(document).on('click','.vote_btn',function(){
        
       // var active_id = "{$active.id}";
        //if(active_id == 25){
            var _this = $(this);
            var id = _this.attr('data-id');
            $.post(
                '{:url("do_vote")}',
                'id={$active.id}&channel_id={$channel}&participant_id='+_this.attr('data-user-id'),
                function(data){
                    if(data.code == 0){
                        $('#list'+id).text(parseInt($('#list'+id).text())+parseInt(data.support));
                        $.toast(data.message);
                    }else{
                        $.toast(data.message, "cancel");
                        //$('.iframe-box').show();
                    }
                    // if(data.code != 193){
                    //     _this.parents('.sign-item-btn-box').html('<div class="sign-item-btn msh-btn" onclick="">再送{$number}朵</div>');
                    // }
                },
                'json'
            );
            return false;
       // }else{
            //2018年2月27日11:09:38 禁止微信投票
            //$('.iframe-box').show();
       // }
    });

    var is_jump = 1;
    $(document).on('click','.detail-jump',function(){
        if(is_jump == 1){
            location.href = '{:url("detail",["id"=>$active.id,"channel_id"=>$channel])}?user_id='+$(this).attr('data-user-id');
        }
    });

    // $(document).on('click','.close',function(){
    //     $('.iframe-box').hide();
    // });

    // $(document).on('click','.msh-btn',function(){
    //     $('.iframe-box').show();
    // });

    // $('.iframe-box').click(function(){
    //     $(this).hide();
    // });
</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
    //初始化配置信息

            wx.config({
                debug: false,
                appId: '{$wxconfig.appId}', 
                timestamp: '{$wxconfig.timestamp}', 
                nonceStr: '{$wxconfig.nonceStr}', 
                signature: '{$wxconfig.signature}',
                jsApiList: [
                    'checkJsApi',
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'onMenuShareQZone'
                ]
            });
            var share_title = '{$active.share_info.title}';
            var share_desc = '{$active.share_info.intro}';
            var share_link = '{$active.share_info.url}/channel_id/{$channel}';
            var share_imgUrl = '{$active.share_info.img}';
            var share_type = '';
            var share_dataUrl = '';

            wx.ready(function () {
                // 分享到朋友圈
                wx.onMenuShareTimeline({ title: share_title, link: share_link, imgUrl: share_imgUrl });
                // 分享给朋友
                wx.onMenuShareAppMessage({ title: share_title, desc: share_desc, link: share_link, imgUrl: share_imgUrl, type: share_type, dataUrl: share_dataUrl });
                // 分享到QQ
                wx.onMenuShareQQ({ title: share_title, desc: share_desc, link: share_link, imgUrl: share_imgUrl });
                // 分享到腾讯微博
                wx.onMenuShareWeibo({ title: share_title, desc: share_desc, link: share_link, imgUrl: share_imgUrl });
                // 分享到QQ空间
                wx.onMenuShareQZone({ title: share_title, desc: share_desc, link: share_link, imgUrl: share_imgUrl });
            });


</script>
</body>
</html>